IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[spDriver_InsertDriver]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[spDriver_InsertDriver]
GO

GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Eric Liew
-- Create date: 6/2/2009
-- Description:	Insert Driver
-- =============================================
CREATE PROCEDURE [dbo].[spDriver_InsertDriver]
(

		@Title VARCHAR(50),
		@FirstName VARCHAR(50),
		@LastName VARCHAR(50),
		@Street1 VARCHAR(50),
		@Street2 VARCHAR(50),
		@Suburb VARCHAR(50),
		@State VARCHAR(50),
		@Postcode VARCHAR(4),
		@Phone VARCHAR(10),
		@Mobile1 VARCHAR(10),
		@Mobile2 VARCHAR(10),
		@Licience VARCHAR(10),
		@DriverLicienceExpiry DATETIME,
		@TaxiLicience VARCHAR(10),
		@ABN VARCHAR(20),
		@DateOfBirth DATETIME,
		@CommencementDate DATETIME,
		@Nickname VARCHAR(50),
		@TaxiLicienceExpiry DATETIME,
		@ETagNumber VARCHAR(50),
		@ETagAccount VARCHAR(50),
		@Gender INT,
		@MonDayRate VARCHAR(50),
		@MonNightRate VARCHAR(50),
		@TuesDayRate VARCHAR(50),
		@TuesNightRate VARCHAR(50),
		@WedDayRate VARCHAR(50),
		@WedNightRate VARCHAR(50),
		@ThursDayRate VARCHAR(50),
		@ThursNightRate VARCHAR(50),
		@FriDayRate VARCHAR(50),
		@FriNightRate VARCHAR(50),
		@SatDayRate VARCHAR(50),
		@SatNightRate VARCHAR(50),
		@SunDayRate VARCHAR(50),
		@SunNightRate VARCHAR(50)
	
)

AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	DECLARE @DriverId int;


	INSERT Driver
	(Title, FirstName, LastName, Street1, Street2, Suburb, 
	State, Postcode, Phone, Mobile1, Mobile2, Licience, 
	DriverLicienceExpiry, TaxiLicience, ABN, DateOfBirth,
	CommencementDate, Nickname, TaxiLicienceExpiry, ETagNumber, ETagAccount,
	Active,Gender)
	VALUES
	(@Title, @FirstName, @LastName, @Street1, @Street2, @Suburb,
	@State, @Postcode, @Phone, @Mobile1, @Mobile2, @Licience,
	@DriverLicienceExpiry, @TaxiLicience, @ABN, @DateOfBirth,
	@CommencementDate, @Nickname, @TaxiLicienceExpiry, @ETagNumber, @ETagAccount,
	1, @Gender) 	

	SET @DriverId = @@IDENTITY 
 
	INSERT DriverRate
	(DriverId,MonDayRate,MonNightRate,TuesDayRate,TuesNightRate,
	WedDayRate,WedNightRate,ThursDayRate,ThursNightRate,
	FriDayRate,FriNightRate,SatDayRate,SatNightRate,SunDayRate,SunNightRate)
	VALUES
	(@DriverId, @MonDayRate, @MonNightRate, @TuesDayRate, @TuesNightRate,
	@WedDayRate, @WedNightRate, @ThursDayRate, @ThursNightRate, 
	@FriDayRate, @FriNightRate, @SatDayRate, @SatNightRate, @SunDayRate, @SunNightRate)


END
GO
